package cn.bingo.yunsj.quartz;

import cn.bingo.yunsj.ascept.LogAdvice;
import cn.bingo.yunsj.common.exception.EmException;
import cn.bingo.yunsj.common.exception.OwnException;
import cn.bingo.yunsj.scan.ScanMysql;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

@Component
@EnableScheduling
public class SecondJob implements Job {

    private static final Logger logger= LoggerFactory.getLogger(SecondJob.class);

    /**
     * 发送贺卡扫描逻辑方法
     * @param context
     * @throws JobExecutionException
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        }catch (Exception e){
            throw new OwnException(EmException.SYSTEM_EXCPTION,e.getMessage());
        }
        logger.info("schedule job2 is running ……………………………………………………");
        ScanMysql scanMysql = StaticAppContext.getContext().getBean(ScanMysql.class);
        scanMysql.sacnMysql();
    }
}
